#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e8+9;
bool primes[maxn];
void sieve() {
  memset(primes, true, sizeof(primes));
  primes[0]=primes[1]=false;
  for(long long i=2; i<maxn; ++i) {
    if(primes[i]) {
      for(long long j=i*i; j<maxn; j+=i) {
        primes[j]=false;
      }
    }
  }
}
long long sum = 0;
int main() {
  sieve();
  int count = 0;
  for(int i=2; i<2000000; ++i) {
    if(primes[i]) {
      sum += i;
    }
  }
  cout<<sum<<endl;
}
